Recent Components page, RSS feed #131
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi folks.
This PR adds a new "Recent Components" page, and "Recent Components" RSS feed.
A couple more, small, build scripts were added -- check
build.js
componentsBuildList
,componentsBuildIndex
,componentsBuildRSS
,Note that
componentsBuildList
now uses the Git api (vianodegit
) to find when a component was first committed to the repo. Took me some gitter/slack back and forth with thenodegit
people, but I think this is robust to renaming and moving the component around. This introduces a newcreationTime
key in the component list (the temporary JSON file), which is leveraged later on. I also store a newauthor
key, which is used in the RSS feed. Note that all this querying of the repo slows down this step, but it shouldn't be too bad (about 5 seconds on my laptop for all of the components).The index pages still use the same template file, but new options allow for more flexibility. The list of index pages to build is in
options.components.index
:The
byCategory
key above describes the previously existing index page, the one listing all components by category. These options can be passed to a small function incomponents-build-sections
that return a new list of components organized by sections. In the above example,src
attribute (the path on disk),limitAll
isfalse
),category
key on each component,Now here is another index, and that's all it takes to describe the new "Recent Components" page:
creationTime
attribute, most recent first,false
if you prefer to list all of them,creationTime
key, but I thought it looked better when grouping all components created the same day together. ThecreationTimeToYMD
callback takes a component and return whatever value you want to group components by (e.g. the section) -- in this case it converts the component creation time (milliseconds) to aYYYY-MM-DD
format. Change it back to'creationTime'
if you'd prefer a section for each component.prettifySection
is a callback that will format the section for display on the page. Here, it converts theYYYY-MM-DD
value to something more human-readable. Remove that property altogether if you end up switchingcreateSectionsBy
back to'creationTime'
, since formatting thecreationTime
property is already handled by theoptions.components.prettify.creationTime
callback.The
options.components.rss
object should be self-explanatory:I decided to only include 20 of the most recent components in that feed, that's a common value for feeds; feel free to customize.
Building a RSS feed that properly features the component screenshot was... tricky. I tried RSS enclosures, RSS custom elements -- no dice. I ended up looking at how http://unsplash.com does it. It seems to work fine. For RSS auto-discovery I added this to the
templates/head.html
:This should hopefully let you put any pages from http://tachyons.io inside a RSS feed reader, and get the RSS feed directly.
What I leave up to you:
components/recent.html
) is not referenced from any other page right now. Feel free to add a link to it from the header? Making it look good is not my area of expertise :)http://tachyons.io/components/rss.xml
-- RSS auto-discovery should work, but feel free to explicitly mention the feed on the home page.Let me know if you have any questions, feedback, etc.